<?php if(!defined('HOST'))die('not access');?>
<style>
.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{vertical-align:middle;}
.input, .select, .textarea {line-height: 20px;}
#veiw_{rand} td>div{display: flex;align-items: center;padding: 0;}
</style>
<script>
(function (window) {
    // 将小数点清零
    var toInteger_zhaobiaoqingkuanghuizong = function (value) {
    value = Math.round(parseFloat(value));
    return value;
    };
    // 保留一位小数点
    var toDecimal_zhaobiaoqingkuanghuizong = function (value) {
    value = Math.round(parseFloat(value) * 10) / 10;
    if (value.toString().indexOf(".") < 0) {
    value = value.toString() + ".0";
    }
    return value;
    }
    // 保留两位小数点
    var toFloat_zhaobiaoqingkuanghuizong = function (value) {
    value = Math.round(parseFloat(value) * 100) / 100;
    if (value.toString().indexOf(".") < 0) {
    value = value.toString() + ".00";
    }
    return value;
    }
    // 保留两位小数点，一位小数自动补零
    var toZero_zhaobiaoqingkuanghuizong = function (value) {
    value = Math.round(parseFloat(value) * 100) / 100;
    var xsd = value.toString().split(".");
    //Ext.log(xsd.length);
    if (xsd.length == 1) {
    value = value.toString() + ".00";
    return value;
    }
    if (xsd.length > 1) {
    if (xsd[1].length < 2) {
    value = value.toString() + "0";
    }
    return value;
    }
    }
    window.fomatFloat = {
    toInteger_zhaobiaoqingkuanghuizong: toInteger_zhaobiaoqingkuanghuizong,
    toDecimal_zhaobiaoqingkuanghuizong: toDecimal_zhaobiaoqingkuanghuizong,
    toFloat_zhaobiaoqingkuanghuizong: toFloat_zhaobiaoqingkuanghuizong,
    toZero_zhaobiaoqingkuanghuizong: toZero_zhaobiaoqingkuanghuizong,
    };
})(window);
// 方法，若为null 显示为短横线'-'
function reline(data){
}
// 调整表头与表格对齐的方法
function fun_table_width_zhaobiaoqingkuanghuizong() {
    var box_h = $('.table-box').height()
    var con_h = $('#veiw_{rand}').height()
    if (con_h > box_h) {$('#table_h').css('width', '99.4%')}
    else {$('#table_h').css('width', '100%')}
}
//列表展示
function summaryLists_zhaobiaoqingkuanghuizong(params = new Object()){
    $.ajax({ url:js.getajaxurl('getProjectInfoList','{mode}','{dir}'), data:params, success: function(obj){
        obj = JSON.parse(obj);
        var data = obj.rows;
        var mergeids = '';
        var projectNum = 0;
        var budgetTotal = 0.00;
        var companyName = "";
        //总计
        var totalPrice = 0.00;
        //序号
        var No = 0;
        var len = data.length - 1;
        //定义表头
        var content = "<table class='table table-bordered table-hover' style='position:relative;table-layout: fixed;word-break:break-all; word-wrap:break-all;'>";
        content += "<thead>";
        // content += "<thead><tr style=''>" +
        //     // "<td>勾选</td>" +
        //     "<td>序号</td>" +
        //     "<td width='60'>单位</td>" +
        //     "<td width='80'>项目名称</td>" +
        //     "<td>批准书文号<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td width='80'>批准书获得时间<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>采购类别</td>" +
        //     "<td width='80'>采购方式</td>" +
        //     "<td>预算金额<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>审减后金额<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>中标金额<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>节约金额(预算节约)<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>节约金额(审减节约)<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>节约率(预算)<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>节约率(审减)<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td width='80'>代理机构<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>报名单位情况<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>公告时间<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>开标时间<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>完标时间<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>中标单位<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>合同是否签订<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>档案整理情况<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>项目进展情况<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td>备注<i class='glyphicon glyphicon-edit'></i></td>" +
        //     "<td width='60'>项目负责人</td>" +
        //     "<td width='60'>操作</td>" +
        //     "</tr></thead>";

        //渲染数据到table
        $.each(data, function(i, field){
            if(isempt(field.projecticp)) {
                field.projecticp = '';
            }
            totalPrice += parseFloat(field.budget);
            budgetTotal += parseFloat(field.budget);
            var mergeid = field.mergeids;
            var radioTmp = '';
            var NoTmp = '';
            var companynameTmp = '';
            var nameTmp = '';
            var projecticpTmp = '';
            var proicptimeTmp = '';
            var typeTmp = '';
            var buymodeTmp = '';
            var proxygovTmp = '';
            var startbiddateTmp = '';
            var projecterNameTmp = '';

            if(mergeids != mergeid && !isempt(mergeid)) {
                No++;
                mergeids = mergeid;
                if(field.countmergeids>0){
                    mergeNum = field.countmergeids;
                }else{
                    mergeNum = mergeid.split(",").length;
                }
                
                // radioTmp = "<td rowspan=\""+mergeNum+"\"><input type='radio' name='id_checked' value='"+field.id+"'></td>";
                NoTmp = "<td width='25' rowspan=\""+mergeNum+"\"><div style='min-height: 5rem;'>"+No+"</div></td>";
                companynameTmp = "<td width='50' rowspan=\""+mergeNum+"\"><div style='min-height: 5rem;'>"+field.companyname+"</div></td>";
                nameTmp = "<td width='50' rowspan=\""+mergeNum+"\"><div style='width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;' class=\"input\" data-name=\"name\" id='"+field.id+"'>"+field.name+"</div></td>";
                projecticpTmp = "<td width='50' rowspan=\""+mergeNum+"\" ><div style='width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;' class=\"input\" data-name=\"projecticp\" id='"+field.id+"'>"+field.projecticp+"</div></td>";
                proicptimeTmp = "<td width='50' rowspan=\""+mergeNum+"\"><div style='width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;' class=\"date\" data-name=\"proicptime\" id='"+field.id+"'>"+field.proicptime+"</div></td>";
                typeTmp = "<td width='50' rowspan=\""+mergeNum+"\"><div style='min-height: 5rem;'>"+field.type+"</div></td>";
                buymodeTmp = "<td width='50' rowspan=\""+mergeNum+"\"><div style='min-height: 5rem;'>"+field.buymode+"</div></td>";
                proxygovTmp = '<td width="50" rowspan="'+mergeNum+'"><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="select" data-name="proxygov" id="'+field.id+'">'+field.proxygov+'</div></td>';
                startbiddateTmp = '<td width="50"  rowspan="'+mergeNum+'"><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="date" data-name="startbiddate" id="'+field.id+'">'+field.startbiddate+'</div></td>';
                projecterNameTmp = "<td width='50' rowspan=\""+mergeNum+"\"><div style='min-height: 5rem;'>"+field.projecterName+"</div></td>";
            } else if(isempt(mergeid)){
                // radioTmp = "<th><input type='radio' name='id_checked' value='"+field.id+"'></th>";
                if(isempt(field.no)) {
                    No++;
                    NoTmp = "<td width='25'>"+No+"</td>";
                }else{
                    NoTmp = "<td width='25'>"+No+"</td>";
                }
                companynameTmp = "<td width='50'><div style='min-height: 5rem;'>"+field.companyname+"</div></td>";
                nameTmp = "<td width='50'><div style='width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;' class=\"input\" data-name=\"name\" id='"+field.id+"'>"+field.name+"</div></td>";
                projecticpTmp = "<td width='50'><div style='width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;' class=\"input\" data-name=\"projecticp\" id='"+field.id+"'>"+field.projecticp+"</div></td>";
                proicptimeTmp = "<td width='50'><div style='width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;' class=\"date\" data-name=\"proicptime\" id='"+field.id+"'>"+field.proicptime+"</div></td>";
                typeTmp = "<td width='50'><div style='min-height: 5rem;'>"+field.type+"</div></td>";
                buymodeTmp = "<td width='50'><div style='min-height: 5rem;'>"+field.buymode+"</div></td>";
                proxygovTmp = '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="select" data-name="proxygov" id="'+field.id+'">'+field.proxygov+'</div></td>';
                startbiddateTmp = '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="date" data-name="startbiddate" id="'+field.id+'">'+field.startbiddate+'</div></td>';
                projecterNameTmp = "<td width='50'><div style='min-height: 5rem;'>"+field.projecterName+"</div></td>";
            }
            if(companyName == field.companyname) projectNum += 1;
            if(companyName != field.companyname && projectNum >0) {

                budgetTotal = eval(budgetTotal-parseFloat(field.budget));
                budgetTotal = fomatFloat.toZero_zhaobiaoqingkuanghuizong(budgetTotal);
                content += "<tr>";
                content += "<th></th>";
                content += "<th colspan='6' align='left'>小计</th>";
                content += "<th colspan='19'>"+budgetTotal+"</th>";
                content += "</tr>";
            }
            if(companyName != field.companyname) {
                companyName = field.companyname;
                budgetTotal = eval(parseFloat(field.budget)-0);
                //budgetTotal = parseInt(field.budget);
                //budgetTotal = fomatFloat.toZero_zhaobiaoqingkuanghuizong(budgetTotal);
                projectNum = 1;
            }
            content += "<tr>";
            // content += radioTmp;
            content += NoTmp;
            content += companynameTmp;
            content += nameTmp;
            content += projecticpTmp;
            content += proicptimeTmp;
            content += typeTmp;
            content += buymodeTmp;
            content += '<td width="75" style="font-weight:none !important;" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="budget" id="'+field.id+'">'+field.budget+'</div></td>';
            content += '<td width="75" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="aftercheckmoney" id="'+field.id+'">'+field.aftercheckmoney+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="zbmoney" id="'+field.id+'">'+field.zbmoney+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="savemoney_ys" id="'+field.id+'">'+field.savemoney_ys+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="savemoney_sj" id="'+field.id+'">'+field.savemoney_sj+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="saverate_ys" id="'+field.id+'">'+field.saverate_ys+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="input" data-placement="bottom" data-name="saverate_sj" id="'+field.id+'">'+field.saverate_sj+'</div></td>';
            content += proxygovTmp;
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;text-overflow:ellipsis;-webkit-line-clamp:3;display:-webkit-box;-webkit-box-orient:vertical;" class="textarea" data-placement="bottom" data-name="signupcompany" id="'+field.id+'">'+field.signupcompany+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="date" data-placement="bottom" data-name="proclamationdate" id="'+field.id+'">'+field.proclamationdate+'</div></td>';
            content += startbiddateTmp;
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="date" data-placement="bottom" data-name="wbtime" id="'+field.id+'">'+field.wbtime+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;text-overflow:ellipsis;-webkit-line-clamp:3;display:-webkit-box;-webkit-box-orient:vertical;" class="textarea"  data-placement="bottom" data-name="zbcompany" id="'+field.id+'">'+field.zbcompany+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;" class="select1" data-placement="bottom" data-name="issignagreement" id="'+field.id+'">'+field.issignagreement+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;overflow:hidden;text-overflow:ellipsis;-webkit-line-clamp:3;display:-webkit-box;-webkit-box-orient:vertical;" class="textarea" data-placement="bottom" data-name="projectfiles" id="'+field.id+'">'+field.projectfiles+'</div></td>';
            content += '<td width="50"><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;text-overflow:ellipsis;-webkit-line-clamp:3;display:-webkit-box;-webkit-box-orient:vertical;" class="textarea" data-placement="bottom" data-name="projectprogress"  id="'+field.id+'">'+field.projectprogress+'</div></td>';
            content += '<td width="50" ><div style="width:100%;height:auto;min-height: 5rem;border:none;overflow:hidden;overflow:hidden;text-overflow:ellipsis;-webkit-line-clamp:3;display:-webkit-box;-webkit-box-orient:vertical;" class="textarea" data-placement="bottom" data-name="gathernote" id="'+field.id+'">'+field.gathernote+'</div></td>';
            content += projecterNameTmp;
            if(!isempt(field.no)) {
                content += '<td width="50"><button class="btn btn-danger btn-xs" onclick="del('+field.id+')">删除</button></td>';
            }else{
                content += '<td width="50"><button class="btn btn-primary btn-xs" onclick="unpacking('+field.id+')">拆包</button>' +
                    '<button class="btn btn-danger btn-xs" onclick="del('+field.id+')">删除</button></td>';
            }
            content += '<td width="50" style="display:none">'+field.id+'</td>';
            content += "</tr>";
            if(len == i && companyName == field.companyname && projectNum >0) {
                budgetTotal = eval(budgetTotal);
                budgetTotal = fomatFloat.toZero_zhaobiaoqingkuanghuizong(budgetTotal);
                content += "<tr>";
                content += "<th></th>";
                content += "<th colspan='6' align='left'>小计</th>";
                content += "<th colspan='19'>"+budgetTotal+"</th>";
                content += "</tr>";
            }
        });
        totalPrice = fomatFloat.toZero_zhaobiaoqingkuanghuizong(totalPrice);
        content += "<tr>";
        content += "<td></td>";
        content += "<td colspan='6' align='left'>总计</td>";
        content += "<th colspan='19'>"+totalPrice+"</th>";
        content += "</tr>";
        content += "</thead>";
        content += "</table>";
        $('#veiw_{rand}').html(content);

        // 表格和表头对齐方法
        fun_table_width_zhaobiaoqingkuanghuizong()

        //编辑input类型
        $('.input').editable({
            type: 'text',
            emptytext: "",
            placement:"bottom",
            url: function (params) { var can = this; editCell(params,this)}
        });
        //编辑date类型
        $('.date').editable({
            placement: 'bottom',
            // showbuttons: 'bottom',
            type: 'date',
            format: 'yyyy-mm-dd',
            clear: '清空',
            emptytext: "", 
            viewformat: 'yyyy-mm-dd',
            datepicker: {inputclass: 'RemoveFocus datepicker-Date', language: 'zh-CN',},
            url: function (params) { var can = this; editCell(params,this)}
        });
        //编辑代理机构类型
        $('.select').editable({
            type: 'select',
            emptytext: "", 
            placement: 'bottom',
            source: getsource_zhaobiaoqingkuanghuizong(),
            url: function (params) { var can = this; editCell(params,this)}
        });
        //编辑是否签订合同
        $('.select1').editable({
            type: 'select',
            placement: 'bottom',
            emptytext: "",
            value: 2, 
            source: [
                {value: '是', text: '是'},
                {value: '否', text: '否'}
            ],
            url: function (params) { var can = this; editCell(params,this)}
        });
        // //编辑textarea类型
        $('.textarea').editable({
            placement: 'bottom',
            type: 'textarea',
            emptytext: "",
            rows: 10, 
            url: function (params) { var can = this; editCell(params,this)}
        });
    }});
}
// 获取代理机构
function getsource_zhaobiaoqingkuanghuizong() {
    var result = [];
    $.ajax({
        url: "./index.php?a=getDljgs&m=index&d=cg&ajaxbool=true",
        success: function(obj){
            obj = JSON.parse(obj);
            data = obj;
            $.each(data, function (key, value) {
                result.push({ value: value.name, text: value.name });
            });
        }
    });
    return result;
}
//修改单元格公用方法
function editCell(params, can) {
    //获取项目id
    parentNode = $(can).parent();
    pid = $(can).attr("id");
    //pid = parentNode.children("div:last").text();
    //获取修改后的值
    var newvalue = params.value;
    var fieldname = params.name;
    //编辑后保存
    $.ajax({
        type: 'POST',
        url: js.getajaxurl('editProjectSummary','{mode}','{dir}'),
        data: {'id':pid, 'value':newvalue, 'fieldname':fieldname},
        success: function (obj) {
            js.msg('success','保存成功');
        }
    });
}
//拆包
function unpacking(id){
    if (isempt(id)){
        js.msg('error','请选中项目');
        return;
    }
    js.ajax(js.getajaxurl('unpacking','{mode}','{dir}'),{id:id},function(s){
        if(s.code == 200) {
            layer.msg('拆包成功');
            var s=$('#name_{rand}').val();
            var type = $("#type_{rand}").val();
            var sdate=$('#search_sdate_{rand}').val();
            var edate=$('#search_edate_{rand}').val();
            var ksdate=$('#search_ksdate_{rand}').val();
            var kedate=$('#search_kedate_{rand}').val();
            var stbudget=$('#stbudget_{rand}').val();
            var enbudget=$('#enbudget_{rand}').val();
            var bugtype=$('#bugtype_{rand}').val();
            var comid=$('#unit_{rand}').val();
            var projectadminer=$('#projectadminer_{rand}').val();
            summaryLists_zhaobiaoqingkuanghuizong({name:s,sdate:sdate,edate:edate, type:type, ksdate:ksdate, kedate:kedate,comid:comid, projectadminer:projectadminer,bugtype:bugtype,stbudget:stbudget,enbudget:enbudget},true);
        }else{
            layer.msg(s.msg);
        }
    },'get,json',false,'');
    summaryLists_zhaobiaoqingkuanghuizong();
}
//删除
function del(id) {
    layer.confirm('是否要删除此项目？', {
        btn: ['是','否'] //按钮
    }, function(){
        js.ajax(js.getajaxurl('delProjectSummary','{mode}','{dir}'),{id:id},function(s){
            if(s.code == 200) {
                layer.msg('删除成功');
                var s=$('#name_{rand}').val();
                var type = $("#type_{rand}").val();
                var sdate=$('#search_sdate_{rand}').val();
                var edate=$('#search_edate_{rand}').val();
                var ksdate=$('#search_ksdate_{rand}').val();
                var kedate=$('#search_kedate_{rand}').val();
                var stbudget=$('#stbudget_{rand}').val();
                var enbudget=$('#enbudget_{rand}').val();
                var bugtype=$('#bugtype_{rand}').val();
                var comid=$('#unit_{rand}').val();
                var projectadminer=$('#projectadminer_{rand}').val();
                summaryLists_zhaobiaoqingkuanghuizong({name:s,sdate:sdate,edate:edate, type:type, ksdate:ksdate, kedate:kedate,comid:comid, projectadminer:projectadminer,bugtype:bugtype,stbudget:stbudget,enbudget:enbudget},true);
            }else{
                layer.msg(s.msg);
            }
        },'post,json',false,'');
    });
}
var c = {
    search:function(){
        var s=$('#name_{rand}').val();
        var type = $("#type_{rand}").val();
        var sdate=$('#search_sdate_{rand}').val();
        var edate=$('#search_edate_{rand}').val();
        var ksdate=$('#search_ksdate_{rand}').val();
        var kedate=$('#search_kedate_{rand}').val();
        var stbudget=$('#stbudget_{rand}').val();
        var enbudget=$('#enbudget_{rand}').val();
        var bugtype=$('#bugtype_{rand}').val();
        var comid=$('#unit_{rand}').val();
        var projectadminer=$('#projectadminer_{rand}').val();
        summaryLists_zhaobiaoqingkuanghuizong({name:s,sdate:sdate,edate:edate, type:type, ksdate:ksdate, kedate:kedate,comid:comid, projectadminer:projectadminer,bugtype:bugtype,stbudget:stbudget,enbudget:enbudget},true);
    },
};
//分页
// function pages(pageNum = 1) {
//     var rand = js.getrand();
//     var page = '';
//     page = '<div style="margin-top:10px" class="btn-toolbar" role="toolbar">'+
//         '<div class="btn-group">'+
//         '<button id="shang_'+rand+'" data-toggle="tooltip" data-placement="top" title="上一页" type="button" class="btn btn-default">&lt;</button>'+
//         '<button type="button" class="btn btn-default"> 第<span>'+pageNum+'</span>页</span></button>'+
//         '<button id="next_'+rand+'" type="button" data-toggle="tooltip" data-placement="top" title="下一页" class="btn btn-default">&gt;</button>'+
//         '<div class="btn-group" style="float:right; padding-top:3px">'+
//         '</div>'+
//         '</div>';
//     $('#page_{rand}').html(page);
//     $('#shang_'+rand+'').click(function(){
//         var param = new Object()
//         if(pageNum == 1) return false;
//
//         //计算当前分页
//         pageNum = pageNum -1;
//         //计算序号
//         No = No - 10;
//
//         //重新加载列表
//         param['page'] = pageNum;
//         summaryLists_zhaobiaoqingkuanghuizong(param);
//         //重新加载分页
//         pages(pageNum)
//     });
//     $('#next_'+rand+'').click(function(){
//         total = totalNum/10;
//         var param = new Object()
//         if(total < (pageNum +1)) return false;
//         pageNum = pageNum + 1;
//         param['page'] = pageNum + 1;
//         summaryLists_zhaobiaoqingkuanghuizong(param);
//         pages(pageNum)
//     });
// }
$(document).ready(function(){
    {params};
    summaryLists_zhaobiaoqingkuanghuizong(params);
    js.initbtn(c);
});
</script>
<div>
<style>.bordernone td{border: none!important;}</style>
<table class="table table-condensed bordernone">
    <tr>
        <td width="100">
            <input class="inputs" id="name_{rand}" placeholder="项目名称" />
        </td>
        <td nowrap width="100">
            <select id="unit_{rand}" class="inputs" >
                <option value="">二级单位</option>
            </select>
        </td>
        <td width="100">
            <select class="inputs" id="type_{rand}">
                <option value="">采购类别</option>
                <option value="货物类">货物类</option>
                <option value="服务类">服务类</option>
                <option value="工程类">工程类</option>
                <option value="电子卖场">电子卖场</option>
            </select>
        </td>
        <td width="100">
            <select id="bugtype_{rand}" class="inputs" >
                <option value="">采购方式</option>
                <option value="单一来源">单一来源</option>
                <option value="公开招标">公开招标</option>
                <option value="竞争性谈判">竞争性谈判</option>
                <option value="竞争性磋商">竞争性磋商</option>
                <option value="询价">询价</option>
                <option value="直采">直采</option>
                <option value="无过程采购">无过程采购</option>
            </select>
        </td>
        <td nowrap>预算金额
            <input value="" class="inputs" id="stbudget_{rand}" style="width:80px;">到
            <input value="" class="inputs" id="enbudget_{rand}" style="width:80px;">
        </td>
        <td>
            项目时间
            <input onclick="js.datechange(this,'date')" value="" class="inputs datesss" inputtype="date" readonly="" name="search_sdate" id="search_sdate_{rand}" style="width:100px;">
            <input onclick="js.datechange(this,'date')" value="" class="inputs datesss" inputtype="date" readonly="" name="search_edate" id="search_edate_{rand}" style="width:100px;">
        </td>
        <td nowrap>
            <div class="btn-group">
                <button class="btn btn-default" id="t_year_{rand}" type="button" style="height:30px;line-height:1;">年</button>
                <button class="btn btn-default" id="t_season_{rand}" type="button" style="height:30px;line-height:1;">季</button>
                <button class="btn btn-default" id="t_month_{rand}" type="button" style="height:30px;line-height:1;">月</button>
           </div>
        </td>
        <td>
            开标时间
            <input onclick="js.datechange(this,'date')" value="" class="inputs datesss" inputtype="date" readonly="" name="search_ksdate" id="search_ksdate_{rand}" style="width:100px;">
            <input onclick="js.datechange(this,'date')" value="" class="inputs datesss" inputtype="date" readonly="" name="search_kedate" id="search_kedate_{rand}" style="width: 100px;">
        </td>
        <td>
            <button class="btn btn-primary" click="search" type="button" style="height:30px;line-height:1;">检索</button>
        </td>
        <td>
            <button class="btn btn-primary" id="downExce_{rand}" type="button" style="height:30px;line-height:1;">下载汇总表</button>
        </td>
        <td>
            <button class="btn btn-primary" id="downExceJHB_{rand}" type="button" style="height:30px;line-height:1;">下载计划表</button>
        </td>
    </tr>
    <tr>
<!--        <td><button class="btn btn-primary" click="unpacking" style="width:89px;height:30px;line-height:1;">拆包</button></td>-->
<!--        <td><button class="btn btn-danger" click="delss" style="width:85px;height:30px;line-height:1;">删除</button></td>-->
    </tr>
</table>
</div>
<div style="min-width:2800px;">
    <table id="table_h" class='table table-bordered table-hover' style='position:relative;table-layout: fixed;word-break:break-all; word-wrap:break-all;margin-bottom:0 !important;width:100%; '>
        <thead>
            <tr style=''>
                <th width='25'>序号</th>
                <th width='50'>单位</th>
                <th width='50'>项目名称<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>批准书文号<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>批准书获得时间<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>采购类别</th>
                <th width='50'>采购方式</th>
                <th width='75'>预算金额<i class='glyphicon glyphicon-edit'></i></th>
                <th width='75'>审减后金额<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>中标金额<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>节约金额(预算节约)<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>节约金额(审减节约)<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>节约率(预算)<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>节约率(审减)<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>代理机构<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>报名单位情况<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>公告时间<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>开标时间<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>完标时间<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>中标单位<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>合同是否签订<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>档案整理情况<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>项目进展情况<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>备注<i class='glyphicon glyphicon-edit'></i></th>
                <th width='50'>项目负责人</th>
                <th width='50'>操作</th>
            </tr>
        </thead>
    </table>
    <div class="table-box" style='height:750px;overflow-y:auto;'>
    <!-- <div class="blank10"></div> -->
    <div id="veiw_{rand}"></div>
    <div id="page_{rand}"></div>
    </div>
</div>
<script>
$(document).ready(function(){
    var date=new Date;
    var y = date.getFullYear()
    $('#search_sdate_{rand}').val(y+'-01-01');

    function loadProjectadminer_zhaobiaoqingkuanghuizong(){
        js.ajax(js.getajaxurl('loadProjectadminner','index','cg'), 
            {
            },function(s){
                var ccc ="<option value=''>--请选择--</option>";
                $.each(s, function(i, field){
                    ccc += "<option value='"+field.id+"'>"+field.name+"</option>";
                });
                $("#projectadminer_{rand}").html(ccc);
        },'get,json',false,'');
        $.ajax({ url: "./index.php?a=getCompanyList&m=main&d=report&ajaxbool=true", success: function(obj){
            var ccc ="<option value=''>二级单位</option>";
            obj = JSON.parse(obj);
            data = obj.rows;
            for(i=0;i<data.length;i++){
                ccc += "<option value='"+data[i].id+"'>"+data[i].name+"</option>";
            };
            $('#unit_{rand}').html(ccc);
        }});
    }
    loadProjectadminer_zhaobiaoqingkuanghuizong();
});
//下載文件
$(document).ready(function(){
    //下载汇总表
    $("#downExce_{rand}").click(function(){
        var name = $('input[id^="name_'+'"]').val();
        var type = $('select[id^="type_'+'"]').val();
        var sdate = $('input[id^="search_sdate_'+'"]').val();
        var edate = $('input[id^="search_edate_'+'"]').val();
        var ksdate = $('input[id^="search_ksdate_'+'"]').val();
        var kedate = $('input[id^="search_kedate_'+'"]').val();
        var stbudget = $('input[id^="stbudget_'+'"]').val();
        var enbudget = $('input[id^="enbudget_'+'"]').val();
        var bugtype=$('#bugtype_{rand}').val();
        var comid=$('#unit_{rand}').val();
        top.location='./index.php?a=zbqkhzb&m=office|index&d=cg&ajaxbool=true&name='+name+'&type='+type+'&sdate='+sdate+'&edate='+edate+'&ksdate='+ksdate+'&kedate='+kedate+'&comid='+comid+'&bugtype='+bugtype+'&stbudget='+stbudget+'&enbudget='+enbudget;
});
    //下载计划表
    $("#downExceJHB_{rand}").click(function(){
        var name = $('input[id^="name_'+'"]').val();
        var type = $('select[id^="type_'+'"]').val();
        var sdate = $('input[id^="search_sdate_'+'"]').val();
        var edate = $('input[id^="search_edate_'+'"]').val();
        var ksdate = $('input[id^="search_ksdate_'+'"]').val();
        var kedate = $('input[id^="search_kedate_'+'"]').val();
        var stbudget = $('input[id^="stbudget_'+'"]').val();
        var enbudget = $('input[id^="enbudget_'+'"]').val();
        var bugtype=$('#bugtype_{rand}').val();
        var comid=$('#unit_{rand}').val();
        window.open('./index.php?a=cgzbjhb&m=office|index&d=cg&ajaxbool=true&name='+name+'&type='+type+'&sdate='+sdate+'&edate='+edate+'&ksdate='+ksdate+'&kedate='+kedate+'&comid='+comid+'&bugtype='+bugtype+'&stbudget='+stbudget+'&enbudget='+enbudget);
    });
    //处理时间
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth();
    var month = month + 1;
    if(month.toString().length == 1) {
        month = '0' + month;
    }
    var day = date.getDate();
    $("#t_year_{rand}").click(function(){
        var sdate=$('#search_sdate_{rand}').val(year+'-01-01');
        var edate=$('#search_edate_{rand}').val(year+'-12-31');
    });
    $("#t_season_{rand}").click(function(){
        stime = '';
        etime = '';
        switch(true) {
            case (month <= 3):
                stime = year+'-01-01';
                etime = year+'-03-31';
                break;
            case (3 < month <= 6):
                stime = year+'-04-01';
                etime = year+'-06-30';
                break;
            case (6 < month <= 9):
                stime = year+'-07-01';
                etime = year+'-09-30';
                break;
            case (9 < month <= 12):
                stime = year+'-10-01';
                etime = year+'-12-31';
                break;
        }
        var sdate=$('#search_sdate_{rand}').val(stime);
        var edate=$('#search_edate_{rand}').val(etime);
    });
    $("#t_month_{rand}").click(function(){
        var lastDay= new Date(year,month,0).getDate();
        var sdate=$('#search_sdate_{rand}').val(year+'-'+month+'-01');
        var edate=$('#search_edate_{rand}').val(year+'-'+month+'-'+lastDay);
    });
});
</script>